<!DOCTYPE html>
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="admin-html/css/font.css">
    <link rel="stylesheet" href="admin-html/css/xadmin.css">
    <script src="admin-html/js/jquery.min.js"></script>
    <script type="text/javascript" src="admin-html/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="admin-html/js/xadmin.js"></script>
	
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
 <body class="layui-body" style="background:#fff;">


  <div class="layui-body" style="margin-top: 200px;">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-header">理财</div>
          <div class="layui-card-body">
			  <from class="layui-form" action="" method="" wid100="" lay-filter="">
				  
					<div class="layui-form-item">
				  <label class="layui-form-label">存款类型</label>
							<div class="layui-col-sm6">
							  <select lay-filter="cnmd" id="select1" name="cdtypeid">
								<option value="" >请选择一个种类</option>
							  </select>
				  </div>
				  </div>
				  <div class="layui-form-item">
					   
					<label class="layui-form-label">利率</label>
					<div class="layui-input-inline" style="width: 80px;">
					  <input type="text" id="rateNumber"  name="cache"  value="" class="layui-input"  disabled="disabled"  >
					</div>
					<div class="layui-form-mid layui-word-aux">单位为年利率(%)</div>
				  </div>
				 
				  <div class="layui-form-item">
					  
				  					<label class="layui-form-label">金额</label>
				  					<div class="layui-input-inline">
				  					  <input type="text" id="money" onchange="jssy()" autocomplete="off" class="layui-input">
				  					</div>
									<span>预计存满一年收益: <a id="howmoney"></a>元</span>
				  </div>
				  <div class="layui-form-item">
					<label class="layui-form-label">密码</label>
					<div class="layui-input-inline">
					  <input type="password" id="password" value="" autocomplete="off" class="layui-input">
					</div>
				  </div>
				  <div class="layui-form-item">
					<div class="layui-input-block">
					  <button class="layui-btn" lay-submit="" lay-filter="set_system_send">确认保存</button>
					</div>
				  </div>
			  
            </from>
          </div>
        </div>
      </div>
    </div>
  </div>


  <script src="../../../layuiadmin/layui/layui.js"></script>
  <script>
  layui.config({
    base: '../../../layuiadmin/' //静态资源所在路径
  }).extend({
    index: 'lib/index' //主入口模块
  }).use(['index', 'set']);
  layui.use(['form'], function() {
	 
                    var form=layui.form;
  				    form.on('select(cnmd)', function(data){
  						    var val=data.value.split("&")[1];
  							changeRate(val);
							jssy();
  		  			 });
					 form.on('submit(set_system_send)', function(data){
						var cdtypeid = $("#select1").val();
						var rcdtypeid = cdtypeid.split("&")[0];
						var money = $("#money").val();
						var password = $("#password").val();
						var data={
							"carCardid":cardid,
							"money":money,
						    "cdtypeid":rcdtypeid,
						    "password":password
						}
						$.ajax({
							url: "http://www.longm.top:8080/lm/ck/dqck",
							type: "post",
							dataType: 'json',
							headers:{
								'Content-Type':'application/json',
								'token':window.localStorage.getItem("token")
								},
							data:JSON.stringify(data),
							success: function (result) {
								if (result.code === 200) {
									layer.msg(result["message"]);
									window.location.href = document.referrer;
								} else {
									layer.msg(result["data"]);
								}
							}
						});
					 	return false;
					 	})
   });
   layui.use(['form'], function() {
	   $.ajax({
	   	url: "http://www.longm.top:8080/lm/rate/Serach",
	   	type: "post",
	   	dataType: 'json',
	   	headers:{'Content-Type':'application/json'},
	   	data:{},
	   	success: function (result) {
	   		console.log(JSON.stringify(result));
	   		if (result.code === 200) {
	   				var data=result.data;
	   				var select=document.querySelector("#select1");
	   				for(i=0;i<data.length;i++)
	   				{
	   					var option=document.createElement("option");
	   					option.value=data[i].cdtypeid+"&"+data[i].rate;
	   					option.innerText=data[i].cdname;
	   					select.appendChild(option);
	   				}
					var form = layui.form;
	   				form.render('select');
	   		} else {
	   			layer.msg(result["message"]);
	   		}
	   	}
	   });
	   });
  </script>
  <script type="application/javascript">
  	  function changeRate(rate)
  	  {
  	  	  document.querySelector("#rateNumber").value=rate;
		  };
	  function jssy()
	  {
		 var rate=document.querySelector("#rateNumber").value;
		 var money=document.querySelector("#money").value;
		 document.querySelector("#howmoney").innerText=money*rate/100;
	  }
  </script>
  <script type="text/javascript">
	  var cardid = localStorage.getItem("cardid");
  </script>
  
<style id="LAY_layadmin_theme">.layui-side-menu,.layadmin-pagetabs .layui-tab-title li:after,.layadmin-pagetabs .layui-tab-title li.layui-this:after,.layui-layer-admin .layui-layer-title,.layadmin-side-shrink .layui-side-menu .layui-nav>.layui-nav-item>.layui-nav-child{background-color:#20222A !important;}.layui-nav-tree .layui-this,.layui-nav-tree .layui-this>a,.layui-nav-tree .layui-nav-child dd.layui-this,.layui-nav-tree .layui-nav-child dd.layui-this a{background-color:#009688 !important;}.layui-layout-admin .layui-logo{background-color:#20222A !important;}</style></body>
 </html>